#include<stdio.h>
int main(){
	int n;
	int z=0;
	int a,b,c,d,e,f,g;
	int x1,x2,x3,x4,x5,x6,x7;
	int y1=0;
	int y2=0;
	int y3=0;
	int y4=0;
	int y5=0;
	int y6=0;
	int y7=0;
	scanf("%d",&n);
	scanf("%d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g);
	for(int i=1;i<=n;i++){
	scanf("%d %d %d %d %d %d %d",&x1,&x2,&x3,&x4,&x5,&x6,&x7);
	if(x1==a||x1==b||x1==c||x1==d||x1==e||x1==f||x1==g){
	z++;
	}
	if(x2==a||x2==b||x2==c||x2==d||x2==e||x2==f||x2==g){
		z++;
		}
		if(x3==a||x3==b||x3==c||x3==d||x3==e||x3==f||x3==g){
			z++;
			}
			if(x4==a||x4==b||x4==c||x4==d||x4==e||x4==f||x4==g){
				z++;
				}
				if(x5==a||x5==b||x5==c||x5==d||x5==e||x5==f||x5==g){
					z++;
					}
					if(x6==a||x6==b||x6==c||x6==d||x6==e||x6==f||x6==g){
						z++;
						}if(x7==a||x7==b||x7==c||x7==d||x7==e||x7==f||x7==g){
							z++;
							}
							if(z==1){y1++;
						
							}
							if(z==2){y2++;}
							if(z==3){y3++;}
							if(z==4){y4++;}
							if(z==5){y5++;}
							if(z==6){y6++;}
							if(z==7){y7++;}
							z=0;
							
	}
	printf("%d %d %d %d %d %d %d",y7,y6,y5,y4,y3,y2,y1);
	return 0;
}
